<?php

namespace App\Http\Controllers\Api\O1\User;

use Illuminate\Http\Request;
use Biz\Services\User\UserService;
use Lumen\Http\Resources\Json\DataResourceResponse;
use Laravel\Lumen\Routing\Controller as BaseController;

/**
 * CheckController.
 *
 * @license [http://www.85do.com] [杭州永奥网络科技有限公司]
 * @copyright Copyright (c) 2018-2026 Hangzhou Yongao Technology Co., Ltd. All rights reserved.
 */
class CheckController extends BaseController
{
    /**
     * @var mixed
     */
    protected $service;

    /**
     * PageController constructor.
     *
     * @param UserService $service
     */
    public function __construct(UserService $service)
    {
        $this->service = $service;
    }

    /**
     * Check Email.
     *
     * @param Request $request
     *
     * @return \Illuminate\Http\Response
     */
    public function email(Request $request)
    {
        $email = $request->get('email', '');
        $user  = $this->service->findByEmail($email);

        $result = false;
        if ($user) {
            $result = true;
        }

        return new DataResourceResponse([
            'result' => $result,
        ]);
    }
}
